const Sequelize = require("sequelize");
const db = require('../DBConfig/config');
const TouristPlace = require("./touristPlace");

const OrderList = db.define('order_list', {
    id: {
        type: Sequelize.INTEGER(11),
        allowNull: false,
        primaryKey: true,
        autoIncrement: true
    },
    tourist_place_id: {
        type: Sequelize.INTEGER(11),
        allowNull: false
    },
    create_time: {
        type: Sequelize.DATE,
        allowNull: false
    },
    update_time: {
        type: Sequelize.DATE
    },
    status: {
        type: Sequelize.TINYINT
    },
    user_id: {
        type: Sequelize.INTEGER
    },
    contact_name: {
        type: Sequelize.TEXT
    },
    contact_phone: {
        type: Sequelize.TEXT
    },
    contact_email: {
        type: Sequelize.TEXT
    },
    contact_remarks: {
        type: Sequelize.TEXT
    },
    total_price: {
        type: Sequelize.TEXT
    }
}, {
    freezeTableName: true,
    timestamps: false
})

OrderList.belongsTo(TouristPlace, { targetKey: 'id', foreignKey: 'tourist_place_id' })

module.exports = OrderList;